﻿/*---------------------------------------------------------------- 
// Copyright 2005-2016 My Tech. Co. Ltd. All Rights Reserved.
// 版权所有。  
// 
// 文件名： CradleHeadBll
// 文件功能描述： 
// 
//  
// 创建标识： wx2016/11/11 16:38:35
// 
// 修改标识： 
// 修改描述： 
//----------------------------------------------------------------*/

using MyBLL.Dto;
using MyMiddleware;
using MyTool;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyBLL
{
    public class DedroneBll
    {
        private static Device device;

        public static string targetName="";

        public static string state="";

        public static ConcurrentQueue<string> getDedroneQueue;

        /// <summary>
        /// 拆包
        /// </summary>
        /// <param name="pgzDto"></param>
        /// <param name="targets"></param>
        /// <returns></returns>
        public static string UnPacket(byte[] data)
        {
            string packet = "";
            
            
            return packet;
        }

        

        /// <summary>
        /// 发送指令
        /// </summary>
        /// <param name="cmd">指令类型</param>
        /// <param name="device">设备</param>
        /// <returns></returns>
        public static bool GetMessage( Device device)
        {
            //if(device.OnGetData==null)
            device.OnGetData += device_OnGetData1;
            
            return true;
        }

        static void device_OnGetData1(object sender, DataEventArgs args)
        {
            byte[] data = args.MyData;
            string dataStr = UsefulFunction.BytesToMessage(data);
            if (getDedroneQueue == null)
            {
                getDedroneQueue = new ConcurrentQueue<string>();
            }
            else
            {
                getDedroneQueue.Enqueue(dataStr);
            }
        }
    }

}
